//
//  TDAgreementViewController.m
//  TFB
//
//  Created by Nothing on 15/3/18.
//  Copyright (c) 2015年 TD. All rights reserved.
//

#import "TDAgreementViewController.h"

@interface TDAgreementViewController ()

@property (nonatomic, strong) UIScrollView *scrollview;
@property (nonatomic, strong) UILabel *label;

@end

@implementation TDAgreementViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"服务协议";
    self.edgesForExtendedLayout = UIRectEdgeNone;
    self.view.backgroundColor = [UIColor groupTableViewBackgroundColor];
    
    UIScrollView *scrollview = [[UIScrollView alloc] initWithFrame:self.view.bounds];
    self.scrollview = scrollview;
    scrollview.autoresizingMask = self.view.autoresizingMask;
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(5, 5, SVFS.width - 10, 400)];
    self.label = label;
    label.autoresizingMask = scrollview.autoresizingMask;
    label.backgroundColor = [UIColor groupTableViewBackgroundColor];
    label.numberOfLines = 0;
    label.font = [UIFont systemFontOfSize:15];
    NSString *path = [[NSBundle mainBundle] pathForResource:@"agreement" ofType:nil];
    NSString *agreement = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
    
    agreement = [agreement stringByReplacingOccurrencesOfString:@"快付一号" withString:APPNAME];
    agreement = [agreement stringByReplacingOccurrencesOfString:@"上海泰毅金融信息服务有限公司" withString:COMPANY_NAME];
    
    label.text = agreement;
    [scrollview addSubview:label];
   
    [self.view addSubview:scrollview];
}

- (void)viewWillAppear:(BOOL)animated {
    
    [super viewWillAppear:animated];
    
    CGSize size = [self.label sizeThatFits:CGSizeMake(self.label.frame.size.width, 5000)];
    self.label.frame = CGRectMake(5, 5, size.width, size.height);
    self.scrollview.contentSize = CGSizeMake(1, size.height + 10);
}

@end
